<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
 <%@ include file="/WEB-INF/jsp/base/global.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
 
<title>添加博客</title>
</head>
<body>
	<div style="width:500px;">
		<form  id="blogform" action="" method="post" >
			 标题 :<input type="text" name="title" /> <br/>
			 
			    内容 :   <script id="container" name="content" type="text/plain" style="width:800px;height:500px;"></script>
			    <br>
		     
	    </form>
	     <button id="publish" onclick="publishBlog();">发布</button>
	</div>
  
    <!-- 配置文件 -->
    <script type="text/javascript" src="${path}/static/ueditor/ueditor.config.js"></script>
    <!-- 编辑器源码文件 -->
    <script type="text/javascript" src="${path}/static/ueditor/ueditor.all.js"></script>
    <script type="text/javascript" charset="utf-8" src="${path}/static/ueditor/lang/zh-cn/zh-cn.js"></script>
    <script type="text/javascript" src="${path}/static/js/jquery-1.10.2.min.js"></script>
    <!-- 实例化编辑器 -->
    <script type="text/javascript">
        var ue = UE.getEditor('container');
        
        
        function publishBlog(){
        	 console.log(123);
        	 $("#publish").attr('disabled',true);
		     $.ajax({
             //几个参数需要注意一下
                type: "POST",   //方法类型
                dataType: "json",  //预期服务器返回的数据类型
                url: "${path}/blogs/add" ,//url
                data: $("#blogform").serialize(),
                success: function (result) {
                     if(result.code==200){
                    	 alert(result.msg);
                    	 window.location.href="${path}"+result.url;	 
                     }else{
                    	 alert(result.msg);
                    	 $("#publish").attr('disabled',false);
                     }      
                },
                error : function() {
                    alert("异常！");
                }
             });
        	
        }
    </script>
</body>
</html>